#!/usr/bin/env bash
dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -uroot -proot -hhadoop2<<EOF
use sqlserver;
select A.station_id,substr(A.transaction_date,1,7),sum(B.item_quantity)
from ( SELECT transaction_date,transaction_id,station_id from realtime.transactions where substr(transaction_date,1,10)='$dt' )as A
join realtime.transaction_items_oil as B
on A.transaction_id=B.transaction_id and A.station_id=B.station_id
group by A.station_id,substr(A.transaction_date,1,7);
EOF
